package net.hn.hnms.biz.process.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.process.domain.ShiftReporting;
import net.hn.hnms.biz.process.domain.vo.ShiftReportingVo;
import net.hn.hnms.biz.process.service.ShiftReportingService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "一班三汇报控制器", tags = {"一班三汇报控制器"})
@RestController
@RequestMapping("/shiftReporting")
public class ShiftReportingController extends BaseController {

    @Resource
    private ShiftReportingService shiftReportingService;

    @ApiOperation("新增")
    @SaCheckPermission("process:shiftReporting:add")
    @PostMapping("/add")
    @Log(title = "新增一班三汇报", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody ShiftReporting shiftReporting) {
        return toAjax(shiftReportingService.insert(shiftReporting));
    }

    @ApiOperation("删除")
    @SaCheckPermission("process:shiftReporting:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除一班三汇报", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        shiftReportingService.deleteBatch(idList);
        return R.ok();
    }


    @ApiOperation("修改")
    @SaCheckPermission("process:shiftReporting:update")
    @PutMapping("/update")
    @Log(title = "修改一班三汇报", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody ShiftReporting shiftReporting) {
        shiftReportingService.updateById(shiftReporting);
        return R.ok();
    }

    @ApiOperation("分页列表")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<ShiftReportingVo>> page(ShiftReportingVo shiftReportingVo, PageQuery pageQuery) {
        return R.ok(shiftReportingService.selectPageList(shiftReportingVo, pageQuery));
    }


    @ApiOperation("获取详情")
    @GetMapping("/{id}")
    public R<ShiftReportingVo> detail(@PathVariable("id") String id) {
        return R.ok(shiftReportingService.selectDetailById(id));
    }


}
